import {
	SAVE_PROFILE,
	SAVE_USER,
	UPDATE_PROFILE,
	LOGIN_LOGOUT,
} from '@/store/action_types/profile'

let initialValue = {
	user: {},
	profile: {},
}

export default function reducer(state = initialValue, action) {
	const { type, payload } = action
	switch (type) {
		case SAVE_USER:
			return { ...state, user: payload }
		case SAVE_PROFILE:
			return { ...state, profile: payload }
		case UPDATE_PROFILE:
			return {
				...state,
				profile: {
					...state.profile,
					...payload,
				},
			}
		default:
			return state
	}
}
